package com.sensePlusVR.animation;

import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LayoutAnimationController;
import android.view.animation.ScaleAnimation;

public class MyAnimation {

	public static LayoutAnimationController getAnimationControllerVisible(long duration) {
		LayoutAnimationController controller;
		// AnimationSet set = new AnimationSet(true);
		Animation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f);// 从0.5倍放大到1倍
		anim.setDuration(duration);
		controller = new LayoutAnimationController(anim, 0.1f);
		controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
		return controller;
	}

	public static LayoutAnimationController getAnimationControllerInvisible(long duration) {
		LayoutAnimationController controller;
		// AnimationSet set = new AnimationSet(true);
		Animation anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f,
				Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF,
				1.0f);// 从1.0倍放大到0.5倍
		anim.setDuration(duration);
		controller = new LayoutAnimationController(anim, 0.0f);
		controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
		return controller;
	}

	public static AlphaAnimation animationVisible(long duration) {
		AlphaAnimation mShowAction = new AlphaAnimation(0.0f, 1.0f);
		mShowAction.setDuration(duration);
		return mShowAction;
	}
	
	public static AlphaAnimation animationVisible(long duration,long startOffset) {
		AlphaAnimation mShowAction = new AlphaAnimation(0.0f, 1.0f);
		mShowAction.setDuration(duration);
		mShowAction.setStartOffset(startOffset);
		return mShowAction;
	}

	public static AlphaAnimation animationInvisible(long duration) {
		AlphaAnimation mHiddenAction = new AlphaAnimation(1.0f, 0.0f);
		mHiddenAction.setDuration(duration);
		return mHiddenAction;
	}

}
